<template>
	<view class="content">
		<view v-show="persion.name!=''"> 
			<view  class="username">
				{{persion.name}}
			</view>
			<uni-list>
			    <uni-list-item title="管理区域" :disabled="true" :showArrow="false" :rightText="persion.region"></uni-list-item>
				<uni-list-item title="我的职位" :disabled="true" :showArrow="false" :rightText="persion.job"></uni-list-item>
				<uni-list-item title="联系方式" :disabled="true" :showArrow="false" :rightText="persion.phone"></uni-list-item>
				<uni-list-item title="用户性别" :disabled="true" :showArrow="false" :rightText="persion.sex"></uni-list-item>
			</uni-list>
		</view>
		<view v-show="persion.name==''">
			<view class="login">
				<view class="content">
					<!-- 头部logo -->
					<view class="username">
						<view>请登录</view>
					</view>
					<!-- 主体表单 -->
					<view class="main">
						<wInput
							v-model="account"
							type="text"
							maxlength="11"
							placeholder="用户名"
							class="inp"
						></wInput>
						<wInput
							v-model="password"
							type="password"
							maxlength="11"
							placeholder="密码"
							class="inp"
						></wInput>
					</view>
					<wButton
						text="登 录"
						:rotate="isRotate" 
						@click.native="startLogin()"
						class="wbutton"
					></wButton>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	
	import wInput from '../../components/watch-login/watch-input.vue' 
	import wButton from '../../components/watch-login/watch-button.vue' 
	export default {
		data() {
			return {
				response:{},
				persion:{
					region:'新会',
					job:"设备查看员",
					phone:"18318242343",
					name:'',
					sex:'男'
				},
				account: 'ldsAdmin', //用户
				password : 'admin', //密码
				isRotate: false, //是否加载旋转
				
			}
		},
		onLoad() {

		},
		methods: {
		  startLogin(){
			  console.log("进入")
			  let _this = this;
				let requestLogin = uni.request({
				    url: this.$baseUrl+'user/login', //仅为示例，并非真实接口地址。
					 method :'POST',
					 header:{
						 'content-type':'application/x-www-form-urlencoded'
					 },
				    data: {
						 account : _this.account,
						 password : _this.password,
				    },
					success(res) {
						let name = res.data.data.name;
						let token = res.data.data.token;
						_this.persion.name = name;
						uni.setStorage({
							key:'token',
							data:token
						})
					}
				})
			},
			test(){
				console.log(res);
			}
		},
		components: {uniList,uniListItem,wInput,wButton}
	}
</script>

<style lang="scss">
	@import url("../../components/watch-login/css/icon.css");
	@import url("./css/main.css");
	.username{
		text-align: center;
		height: 100%;
		width: 100%;
		}
</style>
